s = "ab"
def func_1(s):
    num_1 = 0
    num_2 = 0
    if len(s) != 1:
        for i in range(0, len(s)-1):
            if s[num_1] == s[num_1+1]:
                num_2 += 1
                num_1 += 1
                if i == len(s)-2:
                    return len(s)

            elif s[num_1] != s[num_1+1]:
                return num_2+1

    else:
        return 1

def fun_2(s):
    s_1 = ""
    s = list(s)
    while len(s) != 0:
        i = func_1(s)
        s_1 += s[i-1]
        s_1 += f"{i}"
        del s[0:i]
    return s_1

a = "aabb"
print(fun_2(a))

# 方法2
def fun(s):
    l = []
    for i in s:
        if not l or l[-2] != i:
            l.append(i)
            l.append(1)
        else:
            l[-1] += 1
    return "".join(map(str, [x for x in l if x != 1]))

print(fun(a))




# python中的逻辑运算符的优先级 1.not 2.and 3.or
print(not 1)
print(not 0)
print(not (0 or 1))
print(not (0 and 1))